home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 3: The Continuation / 17-Bit_The_Continuation_Disc.iso / amigan / amigan 8 / hack.do.c < prev    next >
C/C++ Source or Header  |  1994-01-27  |  18KB  |  750 lines

  1. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  2. /* hack.do.c version 1.0.1 - check Levitation with POT_PARALYSIS
  3.                - added flags.no_rest_on_space */
  4.  
  5. #include <stdio.h>
  6. #include <signal.h>
  7. #include <fcntl.h>
  8. #include "hack.h"
  9. #include "def.func_tab.h"
  10.  
  11. extern char *getenv(),*parse(),*getlogin(),*lowc(),*unctrl();
  12. extern int float_down();
  13. extern char *nomovemsg, *catmore;
  14. extern struct obj *splitobj(), *addinv();
  15. extern boolean hmon();
  16. extern char morc;
  17.  
  18. /*   Routines to do various user commands */
  19.  
  20. int done1();
  21.  
  22. dodrink() {
  23.    register struct obj *otmp,*objs;
  24.    register struct monst *mtmp;
  25.    register int unkn = 0, nothing = 0;
  26.  
  27.    otmp = getobj("!", "drink");
  28.    if(!otmp) return(0);
  29.    switch(otmp->otyp){
  30.    case POT_RESTORE_STRENGTH:
  31.       unkn++;
  32.       pline("Wow!  This makes you feel great!");
  33.       if(u.ustr < u.ustrmax) {
  34.          u.ustr = u.ustrmax;
  35.          flags.botl = 1;
  36.       }
  37.       break;
  38.    case POT_BOOZE:
  39.       unkn++;
  40.       pline("Ooph!  This tastes like liquid fire!");
  41.       Confusion += d(3,8);
  42.       /* the whiskey makes us feel better */
  43.       if(u.uhp < u.uhpmax) losehp(-1, "bottle of whiskey");
  44.       if(!rn2(4)) {
  45.          pline("You pass out.");
  46.          multi = -rnd(15);
  47.          nomovemsg = "You awake with a headache.";
  48.       }
  49.       break;
  50.    case POT_INVISIBILITY:
  51.       if(Invis)
  52.         nothing++;
  53.       else {
  54.         if(!Blind)
  55.           pline("Gee!  All of a sudden, you can't see yourself.");
  56.         else
  57.           pline("You feel rather airy."), unkn++;
  58.         newsym(u.ux,u.uy);
  59.       }
  60.       Invis += rn1(15,31);
  61.       break;
  62.    case POT_FRUIT_JUICE:
  63.       pline("This tastes like fruit juice.");
  64.       lesshungry(20);
  65.       break;
  66.    case POT_HEALING:
  67.       pline("You begin to feel better.");
  68.       flags.botl = 1;
  69.       u.uhp += rnd(10);
  70.       if(u.uhp > u.uhpmax)
  71.          u.uhp = ++u.uhpmax;
  72.       if(Blind) Blind = 1;   /* see on next move */
  73.       if(Sick) Sick = 0;
  74.       break;
  75.    case POT_PARALYSIS:
  76.         if(Levitation)
  77.             pline("Your head is frozen to the ceiling!");
  78.         else
  79.             pline("Your feet are frozen to the floor!");
  80.         nomul(-(rn1(10,25)));
  81.         break;
  82.    case POT_MONSTER_DETECTION:
  83.       if(!fmon) {
  84.          strange_feeling(otmp);
  85.          return(1);
  86.       } else {
  87.          cls();
  88.          for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
  89.             if(mtmp->mx > 0)
  90.             at(mtmp->mx,mtmp->my,mtmp->data->mlet);
  91.          prme();
  92.          pline("You sense the presence of monsters.");
  93.          more();
  94.          docrt();
  95.       }
  96.       break;
  97.    case POT_OBJECT_DETECTION:
  98.       if(!fobj) {
  99.          strange_feeling(otmp);
  100.          return(1);
  101.       } else {
  102.           for(objs = fobj; objs; objs = objs->nobj)
  103.          if(objs->ox != u.ux || objs->oy != u.uy)
  104.             goto outobjmap;
  105.           pline("You sense the presence of objects close nearby.");
  106.           break;
  107.       outobjmap:
  108.          cls();
  109.          for(objs = fobj; objs; objs = objs->nobj)
  110.             at(objs->ox,objs->oy,objs->olet);
  111.          prme();
  112.          pline("You sense the presence of objects.");
  113.          more();
  114.          docrt();
  115.       }
  116.       break;
  117.    case POT_SICKNESS:
  118.       pline("Yech! This stuff tastes like poison.");
  119.       if(Poison_resistance)
  120.     pline("(But in fact it was biologically contaminated orange juice.)");
  121.       losestr(rn1(4,3));
  122.       losehp(rnd(10), "poison potion");
  123.       break;
  124.    case POT_CONFUSION:
  125.       if(!Confusion)
  126.          pline("Huh, What?  Where am I?");
  127.       else
  128.          nothing++;
  129.       Confusion += rn1(7,16);
  130.       break;
  131.    case POT_GAIN_STRENGTH:
  132.       pline("Wow do you feel strong!");
  133.       if(u.ustr == 118) break;
  134.       if(u.ustr > 17) u.ustr += rnd(118-u.ustr);
  135.       else u.ustr++;
  136.       if(u.ustr > u.ustrmax) u.ustrmax = u.ustr;
  137.       flags.botl = 1;
  138.       break;
  139.    case POT_SPEED:
  140.       if(Wounded_legs) {
  141.          if((Wounded_legs & BOTH_SIDES) == BOTH_SIDES)
  142.             pline("Your legs feel somewhat better.");
  143.          else
  144.             pline("Your leg feels somewhat better.");
  145.          Wounded_legs = 0;
  146.          unkn++;
  147.          break;
  148.       }
  149.       if(!(Fast & ~INTRINSIC))
  150.          pline("You are suddenly moving much faster.");
  151.       else
  152.          pline("Your legs get new energy."), unkn++;
  153.       Fast += rn1(10,100);
  154.       break;
  155.    case POT_BLINDNESS:
  156.       if(!Blind)
  157.          pline("A cloud of darkness falls upon you.");
  158.       else
  159.          nothing++;
  160.       Blind += rn1(100,250);
  161.       seeoff(0);
  162.       break;
  163.    case POT_GAIN_LEVEL:
  164.       pluslvl();
  165.       break;
  166.    case POT_EXTRA_HEALING:
  167.       pline("You feel much better.");
  168.       flags.botl = 1;
  169.       u.uhp += d(2,20)+1;
  170.       if(u.uhp > u.uhpmax)
  171.          u.uhp = (u.uhpmax += 2);
  172.       if(Blind) Blind = 1;
  173.       if(Sick) Sick = 0;
  174.       break;
  175.    case POT_LEVITATION:
  176.       if(!Levitation)
  177.          float_up();
  178.       else
  179.          nothing++;
  180.       Levitation += rnd(100);
  181.       u.uprops[PROP(RIN_LEVITATION)].p_tofn = float_down;
  182.       break;
  183.    default:
  184.       pline("What a funny potion! (%d)", otmp->otyp);
  185.       impossible();
  186.       return(0);
  187.    }
  188.    if(nothing) {
  189.        unkn++;
  190.        pline("You have a peculiar feeling for a moment, then it passes.");
  191.    }
  192.    if(otmp->dknown && !objects[otmp->otyp].oc_name_known) {
  193.       if(!unkn) {
  194.          objects[otmp->otyp].oc_name_known = 1;
  195.          u.urexp += 10;
  196.       } else if(!objects[otmp->otyp].oc_uname)
  197.          docall(otmp);
  198.    }
  199.    useup(otmp);
  200.    return(1);
  201. }
  202.  
  203. pluslvl()
  204. {
  205.    register int num;
  206.  
  207.    pline("You feel more experienced.");
  208.    num = rnd(10);
  209.    u.uhpmax += num;
  210.    u.uhp += num;
  211.    u.uexp = (10*pow(u.ulevel-1))+1;
  212.    pline("Welcome to level %d.", ++u.ulevel);
  213.    flags.botl = 1;
  214. }
  215.  
  216. strange_feeling(obj)
  217. register struct obj *obj;
  218. {
  219.    pline("You have a strange feeling for a moment, then it passes.");
  220.    if(!objects[obj->otyp].oc_name_known && !objects[obj->otyp].oc_uname)
  221.       docall(obj);
  222.    useup(obj);
  223. }
  224.  
  225. dodrop() {
  226.    register struct obj *obj;
  227.  
  228.    obj = getobj("0$#", "drop");
  229.    if(!obj) return(0);
  230.    if(obj->olet == '$') {
  231.       if(obj->quan == 0)
  232.          pline("You didn't drop any gold pieces.");
  233.       else {
  234.          mkgold((int) obj->quan, u.ux, u.uy);
  235.          pline("You dropped %u gold piece%s.",
  236.             obj->quan, plur(obj->quan));
  237.          if(Invis) newsym(u.ux, u.uy);
  238.       }
  239.       free((char *) obj);
  240.       return(1);
  241.    }
  242.    return(drop(obj));
  243. }
  244.  
  245. drop(obj) register struct obj *obj; {
  246.    if(obj->owornmask & (W_ARMOR | W_RING)){
  247.       pline("You cannot drop something you are wearing.");
  248.       return(0);
  249.    }
  250.    if(obj == uwep) {
  251.       if(uwep->cursed) {
  252.          pline("Your weapon is welded to your hand!");
  253.          return(0);
  254.       }
  255.       setuwep((struct obj *) 0);
  256.    }
  257.    pline("You dropped %s.", doname(obj));
  258.    dropx(obj);
  259.    return(1);
  260. }
  261.  
  262. dropx(obj) register struct obj *obj; {
  263.    if(obj->otyp == CRYSKNIFE)
  264.       obj->otyp = WORM_TOOTH;
  265.    freeinv(obj);
  266.    obj->ox = u.ux;
  267.    obj->oy = u.uy;
  268.    obj->nobj = fobj;
  269.    fobj = obj;
  270.    if(Invis) newsym(u.ux,u.uy);
  271.    subfrombill(obj);
  272.    stackobj(obj);
  273. }
  274.  
  275. /* drop several things */
  276. doddrop() {
  277.    return(ggetobj("drop", drop, 0));
  278. }
  279.  
  280. rhack(cmd)
  281. register char *cmd;
  282. {
  283.    register struct func_tab *tlist = list;
  284.    boolean firsttime = FALSE;
  285.    register int res;
  286.  
  287.    if(!cmd) {
  288.       firsttime = TRUE;
  289.       flags.nopick = 0;
  290.       cmd = parse();
  291.    }
  292.     if(!*cmd || *cmd == 0377 || (flags.no_rest_on_space && *cmd == ' ')){
  293.         flags.move = 0;
  294.         return;      /* probably we just had an interrupt */
  295.     }
  296.    if(movecm(cmd)) {
  297.    walk:
  298.       if(multi) flags.mv = 1;
  299.       domove();
  300.       return;
  301.    }
  302.    if(movecm(lowc(cmd))) {
  303.       flags.run = 1;
  304.    rush:
  305.       if(firsttime){
  306.          if(!multi) multi = COLNO;
  307.          u.last_str_turn = 0;
  308.       }
  309.       flags.mv = 1;
  310. #ifdef QUEST
  311.       if(flags.run >= 4) finddir();
  312.       if(firsttime){
  313.          u.ux0 = u.ux + u.dx;
  314.          u.uy0 = u.uy + u.dy;
  315.       }
  316. #endif QUEST
  317.       domove();
  318.       return;
  319.    }
  320.    if((*cmd == 'f' && movecm(cmd+1)) ||
  321.       movecm(unctrl(cmd))) {
  322.       flags.run = 2;
  323.       goto rush;
  324.    }
  325.    if(*cmd == 'F' && movecm(lowc(cmd+1))) {
  326.       flags.run = 3;
  327.       goto rush;
  328.    }
  329.    if(*cmd == 'm' && movecm(cmd+1)) {
  330.       flags.run = 0;
  331.       flags.nopick = 1;
  332.       goto walk;
  333.    }
  334.    if(*cmd == 'M' && movecm(lowc(cmd+1))) {
  335.       flags.run = 1;
  336.       flags.nopick = 1;
  337.       goto rush;
  338.    }
  339. #ifdef QUEST
  340.    if(*cmd == cmd[1] && (*cmd == 'f' || *cmd == 'F')) {
  341.       flags.run = 4;
  342.       if(*cmd == 'F') flags.run += 2;
  343.       if(cmd[2] == '-') flags.run += 1;
  344.       goto rush;
  345.    }
  346. #endif QUEST
  347.    while(tlist->f_char) {
  348.       if(*cmd == tlist->f_char){
  349.          res = (*(tlist->f_funct))(0);
  350.          if(!res) {
  351.             flags.move = 0;
  352.             multi = 0;
  353.          }
  354.          return;
  355.       }
  356.       tlist++;
  357.    }
  358.    pline("Unknown command '%s'",cmd);
  359.    multi = flags.move = 0;
  360. }
  361.  
  362. doredraw()
  363. {
  364.    docrt();
  365.    return(0);
  366. }
  367.  
  368. dohelp()
  369. {
  370.     FILE *fp;
  371.     char bufr[BUFSZ];
  372.     int line, i;
  373.     
  374.     if ( (fp = fopen(HELP,"r")) == NULL)
  375.         pline("cannot access help");
  376.     else
  377.         {
  378.         cls();
  379.         line = 1;
  380.         while(fgets(bufr,BUFSZ,fp))
  381.             {
  382.             myprintf("%s", bufr);
  383.             if (line++ > ROWNO)
  384.                 {
  385.                 myprintf("---more---");
  386.                 xwaitforspace(FALSE);
  387.                 morc = 0;
  388.                 for (i=0;i<10;i++)
  389.                     backsp();
  390.                 cl_end();
  391.                 line = 1;
  392.                 }
  393.             }
  394.         more();
  395.         docrt();
  396.         }
  397. }
  398.  
  399. #ifdef SHELL
  400. dosh(){
  401.    char *file, *Open();
  402.    if ( (file = Open("CON:1/1/639/199/Hack SubProcess", 1006)) == NULL)
  403.     pline("cannot create process window");
  404.    if (Execute("", file, NULL))
  405.       pline("cannot execute commands");
  406.    Close(file);
  407.    return(0);
  408. }
  409. #endif SHELL
  410.  
  411. child(wt) {
  412.    pline("Cannot create children");
  413.    docrt();
  414.    return(0);
  415. }
  416.  
  417. dodown()
  418. {
  419.    if(u.ux != xdnstair || u.uy != ydnstair) {
  420.       pline("You can't go down here.");
  421.       return(0);
  422.    }
  423.    if(u.ustuck) {
  424.       pline("You are being held, and cannot go down.");
  425.       return(1);
  426.    }
  427.    if(Levitation) {
  428.       pline("You're floating high above the stairs.");
  429.       return(0);
  430.    }
  431.  
  432.    goto_level(dlevel+1, TRUE);
  433.    return(1);
  434. }
  435.  
  436. doup()
  437. {
  438.    if(u.ux != xupstair || u.uy != yupstair) {
  439.       pline("You can't go up here.");
  440.       return(0);
  441.    }
  442.    if(u.ustuck) {
  443.       pline("You are being held, and cannot go up.");
  444.       return(1);
  445.    }
  446.    if(inv_weight() + 5 > 0) {
  447.       pline("Your load is too heavy to climb the stairs.");
  448.       return(1);
  449.    }
  450.  
  451.    goto_level(dlevel-1, TRUE);
  452.    return(1);
  453. }
  454.  
  455. goto_level(newlevel, at_stairs)
  456. register int newlevel;
  457. register boolean at_stairs;
  458. {
  459.    register int fd;
  460.    register boolean up = (newlevel < dlevel);
  461.  
  462.     if(newlevel <= 0) done("escaped");    /* in fact < 0 is impossible */
  463.     if(newlevel == dlevel) return;          /* this cannot happen either */
  464.  
  465.    glo(dlevel);
  466.    fd = creat(lock,FMASK);
  467.    if(fd < 0) {
  468.       /*
  469.        * This is not quite impossible: e.g., we may have
  470.        * exceeded our quota. If that is the case then we
  471.        * cannot leave this level, and cannot save either.
  472.        */
  473.       pline("A mysterious force prevents you from going %s.",
  474.          up ? "up" : "down");
  475.       return;
  476.    }
  477.  
  478.    if(Punished) unplacebc();
  479.    keepdogs();
  480.    seeoff(1);
  481.    flags.nscrinh = 1;
  482.    u.ux = FAR;            /* hack */
  483.    (void) inshop();         /* probably was a trapdoor */
  484.  
  485.    savelev(fd);
  486.    (void) close(fd);
  487.  
  488.    dlevel = newlevel;
  489.    if(maxdlevel < dlevel)
  490.       maxdlevel = dlevel;
  491.    glo(dlevel);
  492.    if((fd = open(lock,0)) < 0)
  493.       mklev();
  494.    else {
  495.       (void) getlev(fd);
  496.       (void) close(fd);
  497.    }
  498.  
  499.    if(at_stairs) {
  500.        if(up) {
  501.       u.ux = xdnstair;
  502.       u.uy = ydnstair;
  503.       if(!u.ux) {      /* entering a maze from below? */
  504.           u.ux = xupstair;   /* this will confuse the player! */
  505.           u.uy = yupstair;
  506.       }
  507.       if(Punished){
  508.          pline("With great effort you climb the stairs");
  509.          placebc(1);
  510.       }
  511.        } else {
  512.       u.ux = xupstair;
  513.       u.uy = yupstair;
  514.       if(inv_weight() + 5 > 0 || Punished){
  515.          pline("You fall down the stairs.");
  516.          losehp(rnd(3), "fall");
  517.          if(Punished) {
  518.              if(uwep != uball && rn2(3)){
  519.             pline("... and are hit by the iron ball");
  520.             losehp(rnd(20), "iron ball");
  521.              }
  522.              placebc(1);
  523.          }
  524.          selftouch("Falling, you");
  525.       }
  526.        }
  527.    } else {   /* trapdoor or level_tele */
  528.        do {
  529.       u.ux = rnd(COLNO-1);
  530.       u.uy = rn2(ROWNO);
  531.        } while(levl[u.ux][u.uy].typ != ROOM ||
  532.          m_at(u.ux,u.uy));
  533.        if(Punished){
  534.       if(uwep != uball && !up /* %% */ && rn2(5)){
  535.          pline("The iron ball falls on your head.");
  536.          losehp(rnd(25), "iron ball");
  537.       }
  538.       placebc(1);
  539.        }
  540.        selftouch("Falling, you");
  541.    }
  542.    (void) inshop();
  543. #ifdef TRACK
  544.    initrack();
  545. #endif TRACK
  546.  
  547.    losedogs();
  548.    flags.nscrinh = 0;
  549.    setsee();
  550.     { register struct monst *mtmp;
  551.       if(mtmp = m_at(u.ux, u.uy)) mnexto(mtmp);    /* riv05!a3 */
  552.     }
  553.    docrt();
  554.    pickup();
  555.    read_engr_at(u.ux,u.uy);
  556. }
  557.  
  558. donull() {
  559.    return(1);   /* Do nothing, but let other things happen */
  560. }
  561.  
  562. struct monst *bhit(), *boomhit();
  563. dothrow()
  564. {
  565.    register struct obj *obj;
  566.    register struct monst *mon;
  567.    register int tmp;
  568.  
  569.     obj = getobj("#)", "throw");   /* it is also possible to throw food */
  570.                        /* (or jewels, or iron balls ... ) */
  571.    if(!obj || !getdir())
  572.       return(0);
  573.    if(obj->owornmask & (W_ARMOR | W_RING)){
  574.       pline("You can't throw something you are wearing");
  575.       return(0);
  576.    }
  577.    if(obj == uwep){
  578.       if(obj->cursed){
  579.          pline("Your weapon is welded to your hand");
  580.          return(1);
  581.       }
  582.       if(obj->quan > 1)
  583.          setuwep(splitobj(obj, 1));
  584.       else
  585.          setuwep((struct obj *) 0);
  586.    }
  587.    else if(obj->quan > 1)
  588.       (void) splitobj(obj, 1);
  589.    freeinv(obj);
  590.    if(u.uswallow) {
  591.       mon = u.ustuck;
  592.       bhitpos.x = mon->mx;
  593.       bhitpos.y = mon->my;
  594.    } else if(obj->otyp == BOOMERANG) {
  595.       mon = boomhit(u.dx,u.dy);
  596.       /* boomhit delivers -1 if the thing was caught */
  597.       if((int) mon == -1) {
  598.          (void) addinv(obj);
  599.          return(1);
  600.       }
  601.    } else
  602.       mon = bhit(u.dx,u.dy,
  603.          (!Punished || obj != uball) ? 8 :
  604.             !u.ustuck ? 5 : 1,
  605.          obj->olet);
  606.    if(mon) {
  607.       /* awake monster if sleeping */
  608.       wakeup(mon);
  609.  
  610.       if(obj->olet == WEAPON_SYM) {
  611.          tmp = -1+u.ulevel+mon->data->ac+abon();
  612.          if(obj->otyp < ROCK) {
  613.             if(!uwep ||
  614.                 uwep->otyp != obj->otyp+(BOW-ARROW))
  615.                tmp -= 4;
  616.             else {
  617.                tmp += uwep->spe;
  618.             }
  619.          } else
  620.          if(obj->otyp == BOOMERANG) tmp += 4;
  621.          tmp += obj->spe;
  622.          if(u.uswallow || tmp >= rnd(20)) {
  623.             if(hmon(mon,obj,1) == TRUE){
  624.               /* mon still alive */
  625. #ifndef NOWORM
  626.               cutworm(mon,bhitpos.x,bhitpos.y,obj->otyp);
  627. #endif NOWORM
  628.             } else mon = 0;
  629.             /* weapons thrown disappear sometimes */
  630.             if(obj->otyp < BOOMERANG && rn2(3)) {
  631.                /* check bill; free */
  632.                obfree(obj, (struct obj *) 0);
  633.                return(1);
  634.             }
  635.          } else miss(objects[obj->otyp].oc_name, mon);
  636.       } else if(obj->otyp == HEAVY_IRON_BALL) {
  637.          tmp = -1+u.ulevel+mon->data->ac+abon();
  638.          if(!Punished || obj != uball) tmp += 2;
  639.          if(u.utrap) tmp -= 2;
  640.          if(u.uswallow || tmp >= rnd(20)) {
  641.             if(hmon(mon,obj,1) == FALSE)
  642.                mon = 0;   /* he died */
  643.          } else miss("iron ball", mon);
  644.       } else {
  645.          if(cansee(bhitpos.x,bhitpos.y))
  646.             pline("You miss %s.",monnam(mon));
  647.          else pline("You miss it.");
  648.          if(obj->olet == FOOD_SYM && mon->data->mlet == 'd')
  649.             if(tamedog(mon,obj)) return(1);
  650.          if(obj->olet == GEM_SYM && mon->data->mlet == 'u'){
  651.           if(obj->dknown && objects[obj->otyp].oc_name_known){
  652.            if(objects[obj->otyp].g_val > 0){
  653.              u.uluck += 5;
  654.              goto valuable;
  655.            } else {
  656.              pline("%s is not interested in your junk.",
  657.             Monnam(mon));
  658.            }
  659.           } else { /* value unknown to @ */
  660.              u.uluck++;
  661.          valuable:
  662.              pline("%s graciously accepts your gift.",
  663.             Monnam(mon));
  664.              mpickobj(mon, obj);
  665.              rloc(mon);
  666.              return(1);
  667.           }
  668.          }
  669.       }
  670.    }
  671.    obj->ox = bhitpos.x;
  672.    obj->oy = bhitpos.y;
  673.    obj->nobj = fobj;
  674.    fobj = obj;
  675.    /* prevent him from throwing articles to the exit and escaping */
  676.    /* subfrombill(obj); */
  677.    stackobj(obj);
  678.    if(Punished && obj == uball &&
  679.       (bhitpos.x != u.ux || bhitpos.y != u.uy)){
  680.       freeobj(uchain);
  681.       unpobj(uchain);
  682.       if(u.utrap){
  683.          if(u.utraptype == TT_PIT)
  684.             pline("The ball pulls you out of the pit!");
  685.          else {
  686.              register long side =
  687.             rn2(3) ? LEFT_SIDE : RIGHT_SIDE;
  688.              pline("The ball pulls you out of the bear trap.");
  689.              pline("Your %s leg is severely damaged.",
  690.             (side == LEFT_SIDE) ? "left" : "right");
  691.              Wounded_legs |= side + rnd(1000);
  692.              losehp(2, "thrown ball");
  693.          }
  694.          u.utrap = 0;
  695.       }
  696.       unsee();
  697.       uchain->nobj = fobj;
  698.       fobj = uchain;
  699.       u.ux = uchain->ox = bhitpos.x - u.dx;
  700.       u.uy = uchain->oy = bhitpos.y - u.dy;
  701.       setsee();
  702.       (void) inshop();
  703.    }
  704.    if(cansee(bhitpos.x, bhitpos.y)) prl(bhitpos.x,bhitpos.y);
  705.    return(1);
  706. }
  707.  
  708. /* split obj so that it gets size num */
  709. /* remainder is put in the object structure delivered by this call */
  710. struct obj *
  711. splitobj(obj, num) register struct obj *obj; register int num; {
  712. register struct obj *otmp;
  713.    otmp = newobj(0);
  714.    *otmp = *obj;      /* copies whole structure */
  715.    otmp->o_id = flags.ident++;
  716.    otmp->onamelth = 0;
  717.    obj->quan = num;
  718.    obj->owt = weight(obj);
  719.    otmp->quan -= num;
  720.    otmp->owt = weight(otmp);   /* -= obj->owt ? */
  721.    obj->nobj = otmp;
  722.    if(obj->unpaid) splitbill(obj,otmp);
  723.    return(otmp);
  724. }
  725.  
  726. char *
  727. lowc(str)
  728. register char *str;
  729. {
  730.    static char buf[2];
  731.  
  732.    if(*str >= 'A' && *str <= 'Z') *buf = *str+'a'-'A';
  733.    else *buf = *str;
  734.    buf[1] = 0;
  735.    return(buf);
  736. }
  737.  
  738. char *
  739. unctrl(str)
  740. register char *str;
  741. {
  742.    static char buf[2];
  743.    if(*str >= ('A' & 037) && *str <= ('Z' & 037))
  744.       *buf = *str + 0140;
  745.    else *buf = *str;
  746.    buf[1] = 0;
  747.    return(buf);
  748. }
  749.  
  750.